# # # item_one=3
# # # item_two=2
# # # item_three=9
# # # total=item_one +\
# # # item_two +\
# # # item_three
# # # print(total)
# # # word ='word'
# # # sentence="这是一个句子。"
# # # paragraph="这是一个段落。"
# # # print(sentence)
# # # print(paragraph)
# # # print(word)
# # print("hello world")
# # print("hello world")
# # print("hello world")
# x="a"
# y="b"
# #换行输出
# print (x)
# print (y)
# print('--------')
# #不换行输出
# print (x,end='')
# print (y,end='')
# #不换行输出
# print (x+y,end='')
# import sys; x="rko";sys.stdout.write(x+'\n')
# import expression
# import suite
# if expression:
#     suite
# elif expression == "hello":
#     suite
# else:
#     suite
# a,b,c=1,2.22,"hello"
# print(a,b,c)
# #字符串的定义、截取
# s="hello world"
# print(s)
# print(s[0])
# print(s[0:5])
# #复制、连接
# s1=s*2
# print(s1)
# s2=s+"!"
# print(s2)
from random import random

import numpy as np
#list的定义
# lis=["a","aa","aaa","bbcb","1"]
# print(lis)
# print(lis[0])
# print(lis[1])
# print(lis[-1])
# lis[1]="坤坤"
# print(lis[1])
# print(lis[1:3])
# print(lis[1:])
# tinl=[123,'whsjd',"ll"]
# print(lis+tinl)
#元组
# tuple=(1,2.2,'a',"erfdfjv","坤坤")
# print(tuple)
# print(tuple[2])
# tuple[0]=100;
# print(tuple[0])

#字典
# dict={'lf':22,'yk':21,'ll':21,'syz':26}
# print(dict)
# print(dict['lf'])
# print(dict)
# dict['ss']=18
# dict[0]="this is kunking"
# print(dict.keys())
# print(dict.values())
#
# #算术运算符
# a=10
# b=5
# print(a+b)
# print(a-b)
# print(a*b)
# print(a/b)
# print(a**b)
# print(a//b)
# print(a%b)
# #运算符判断
# print(a==b)
# print(a!=b)
# print(a>b)
# print(a<b)
# print(a>=b)
# print(a<=b)

# #+=
# a=10
# b=5
# a+=b
# print(a)
# #位运算符
# a=10
# b=5
# print(a&b)
# print(a|b)
# print(a^b)
# print(~a)
# print(a<<2)
# print(a>>2)
# #逻辑运算符
# a=True
# b=False
# print(a and b)
# print(a or b)
# print(not a)
# #列表的in

#猜数字游戏
#定义一个随机1-100的数字
# import random
# print("请输入一个1-100数字")
# a=int(input("请重新输入"))
# #随机数
# b=int(random.randint(1,100))
# ct=0
# while(1):
#     ct+=1
#     if(a>b):
#         print("你猜的数字大了")
#     elif(a<b):
#         print("你猜的数字小了")
#     else:
#         print("恭喜你猜对了!")
#         break
#     if (ct > 7):
#         print("你的智商余额不足！")
#     a=int(input("请重新输入"))
#实现一个函数，判断一个数是否为素数
# def is_prime(n):
#     if n <= 1:
#         return False
#     for i in range(2, int(n**0.5) + 1):
#         if n % i == 0:
#             return False
#     return True
# #测试
# print(is_prime(11))  # True
# print(is_prime(4))   # False

# #求n以内的所有素数
# def is_prime(n):
#     if n <= 1:
#         return False
#     if n == 2:
#         return True
#     if n % 2 == 0:
#         return False
#     for i in range(2, int(n**0.5) + 1,2):
#         if n % i == 0:
#             return False
#     return True
# #测试
# print(is_prime(11))  # True
# print(is_prime(4))   # False
# #定义一个列表，用于存储素数
# list=[]
# #求n以内的所有素数
# def primes_up_to(n,list):
#     for i in range(2,n+1):
#         if is_prime(i):
#             list.append(i)
#     return list
# #测试
# print(primes_up_to(100,list))  # [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
#
# #求n以内的水仙花数，水仙花数为san'wei数，每个位上的数字的立方和等于它本身
# def narcissistic_numbers_up_to(n):
#     if(n<100 or n>999):
#         return []
#     list=[]
#     for i in range(100,n+1):
#         if i==(i//100)**3+(i//10%10)**3+(i%10)**3:
#             list.append(i)
#     return list
# #测试
# print(narcissistic_numbers_up_to(999))
#
#
# def steps_up_to(n):
#     if n <= 0:
#         return 0
#     if n == 1:
#         return 1
#     if n == 2:
#         return 2
#
#     a, b = 1, 2
#     for _ in range(3, n + 1):
#         a, b = b, a + b
#
#     return b
#
#
# # 测试
# print(steps_up_to(1))  # 输出1
# print(steps_up_to(5))  # 输出8
# #利用递归实现
# def steps_up_to_recursive(n):
#     if n <= 0:
#         return 0
#     if n == 1:
#         return 1
#     if n == 2:
#         return 2
#     return steps_up_to_recursive(n - 1) + steps_up_to_recursive(n - 2)
# #测试
# print(steps_up_to_recursive(1))  # 输出1
# print(steps_up_to_recursive(5))  # 输出8

# #创建一个学生类
# class Student:
#     def __init__(self,name,age,gender):
#         self.name=name
#         self.age=age
#         self.gender=gender
#     def __str__(self):
#         return f"姓名：{self.name}，年龄：{self.age}，性别：{self.gender}"
#
#     # 学生自主学习
#     def learn(self, subject):
#         print(f"{self.name}正在学习{subject}")
# #测试
# s1=Student("坤坤",21,"男")
# print(s1)
# print(s1.name)
# print(s1.age)
# print(s1.gender)
#
# #测试
# s1.learn("Python")  # 输出：坤坤正在学习Python
#列表推导式
#创建一个列表，包含1-10的平方
# list=[i**2 for i in range(1,11)]
# print(list)

import pandas as pd
import matplotlib.pyplot as plt
from sympy import series

plt.rcParams['font.sans-serif'].insert(0,'SimHei')
plt.rcParams['axes.unicode_minus']=False
df3=pd.read_csv(
    '2023年北京积分落户数据.csv',
    # encoding='utf-8',
    # sep='\t',
    # index_col='公示编号',
    # usecols=['公示编号','姓名','积分分值'],
    # nrows=10,
    # skiprows=np.arange(1,20),
    # true_values=['是','yes','Yes','Y'],
    # false_values=['否','no','No','N'],
    # na_values=['---','N/A'],
)
# print(df3.info)
# print(df3.head(3))
# #查看第5行数据
# print(df3.iloc[4])
#查看后5行数据
# print(df3.tail(5))

# df4 =pd.read_excel(
#     '2022年股票数据.xlsx',
#     sheet_name='JD',
#     usecols=['Date','Open','Close'],
#     index_col='Date',
# )
# print(df4.info)
# print(df4.head(3))
# print(df4.tail(3))

#series
#创建一个series，包含1-10的平方
# s1=pd.Series([i**2 for i in range(1,11)])
# print(s1)
# import pandas as pd
# series=pd.Series([1,2,3,4],name='A')#创建一个series，包含1-4的整数
# print(series)
# #显示地设置索引
# series.index=['a','b','c','d']
# print(series)
# #自定义索引
# cIndex=['A','B','C','D']
# series=pd.Series([1,2,3,4],name='A',index=cIndex)
# print(series)

#
#创建一个简单的DataFrame
# df=pd.DataFrame({
#     '姓名':['张三','李四','王五'],
#     '年龄':[20,21,22],
#     '性别':['男','女','男'],
# })
# print(df)
# #将DataFrame写入Excel文件，写入'Sheet1'工作表
# df.to_excel('学生信息.xlsx',sheet_name='Sheet1',index=False)
# # 写入多个表单，使用ExcelWriter
# with pd.ExcelWriter('学生信息.xlsx') as writer:
#     df.to_excel(writer,sheet_name='Sheet1',index=False)
#     # 写入第二个DataFrame到'Sheet2'工作表
#     df2=pd.DataFrame({
#         '姓名':['赵六','钱七','孙八'],
#         '年龄':[23,24,25],
#         '性别':['女','男','女'],
#     })
#     df2.to_excel(writer,sheet_name='Sheet2',index=False)

import pandas as pd
# df=pd.read_csv('property-data.csv')
# print(df['NUM_BEDROOMS'])
# print(df['NUM_BEDROOMS'].isnull())
# print(df['NUM_BEDROOMS'].isnull().sum())
#去掉缺失值
# df.dropna(subset=['PID','ST_NUM'],inplace=True)
# print(df.to_string())
# df=df.dropna(subset=['NUM_BEDROOMS'])
# print(df.to_string())
# 填充缺失值
# df['NUM_BEDROOMS'].fillna(0,inplace=True)
# print(df.to_string())
# df.fillna("未知",inplace=True)
# print(df.to_string())
# df.fillna({
#     'PID':'未知',
#     'ST_NUM':0.0,
#     'NUM_BEDROOMS':0,
# },
#     inplace=True,
# )
# print(df.to_string())
#获取平均值
# x=df['ST_NUM'].mean()
# print(x)
# df.fillna({
#     'ST_NUM':x,
# },
#     inplace=True,
# )
# print(df.to_string())
# #获取中位数
# x=df['ST_NUM'].median()
# print(x)
# #获取众数
# x=df['ST_NUM'].mode()
# print(x)
# person={
#     "name":['张三','李四','王五','李四'],
#     "age":[20,21,122,21],
#     "gender":['男','女','男','女'],
# }
# df=pd.DataFrame(person)
# print(df)
# # for x in df.index:
# #     if df.loc[x,'age']>df['age'].mean():
# #         y=df['age'].mean()
# #         df.loc[x,'age']=y
# # print(df.to_string())
# #获取重复值
# print(df.duplicated())
# #删除重复值
# df.drop_duplicates(inplace=True)
# print(df.to_string())

import requests


# base_url="https://uapis.cn/api/v1/misc/weather"
# url=base_url+"?city=资阳&adcode=110000"
# resp=requests.get(
#     url=url,
# )
# print(resp.json())
# print(resp.json()["weather"])

# base_url="https://uapis.cn/api/v1/misc/phoneinfo"
# url=base_url+"?phone=18900003264"
# resp=requests.get(
#     url=url,
# )
# print(resp.json())
# print(resp.json()["phoneinfo"])

# from openai import OpenAI
#
# client=OpenAI(api_key="sk-bfehxycarcqjljqtzesemtsexijevhrqlhquwhttygdrdfcd",base_url="https://api.siliconflow.cn/v1")
# question=input("请输入您的问题：")
# response=client.chat.completions.create(
# model="deepseek-ai/DeepSeek-V3",
# messages=[
# {"role": "system", "content": "你是一位阿坝师范学院的学生"},
# {"role": "user", "content": question}
# ],
# temperature=0.7,
# max_tokens=1024,
# stream=True
# )
# #逐步接收并处理响应
# for chunk in response:
#     if not chunk.choices:
#         continue
#     if chunk.choices[0].delta.content:
#         print(chunk.choices[0].delta.content,end="",flush=True)
#     if chunk.choices[0].delta.reasoning_content:
#         print(chunk.choices[0].delta.reasoning_content,end="",flush=True)

# import matplotlib.pyplot as plt
# import numpy as np
#
# dx=np.array([3,6])
# dy=np.array([10,100])
#
# plt.plot(dx,dy,'o')
# # plt.show()
# # #添加标题和轴标
# plt.title("简单折线图")
# plt.xlabel("x轴")
# plt.ylabel("y轴")
# # #添加网格线
# # plt.grid(True)
# #添加曲线图例
# # plt.legend(["y=x"])
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 创建数据
# dx = np.array([0, 6])
# dy = np.array([0, 100])
#
# # 绘制图形，并添加标签用于图例
# plt.plot(dx, dy, label="y=x")  # 添加label参数
#
# # 添加标题和轴标签
# plt.title("简单折线图")
# plt.xlabel("x轴")
# plt.ylabel("y轴")
#
# # 添加网格线（可选）
# plt.grid(True)
#
# # 添加图例 - 现在图例有对应的图形了
# plt.legend()
#
# # 显示图形
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 创建x轴数据
# x = np.linspace(-10, 10, 400)  # 从-10到10生成400个点
#
# # 计算不同函数的y值
# y1 = x**2                      # 二次函数
# y2 = np.sin(x)                 # 正弦函数
# y3 = np.exp(x/3)               # 指数函数
# y4 = 1 / (1 + np.exp(-x))      # Sigmoid函数
#
# # 创建子图
# plt.figure(figsize=(12, 8))
#
# # 绘制第一个子图
# plt.subplot(2, 2, 1)
# plt.plot(x, y1, 'r-', linewidth=2)
# plt.title('二次函数: y = x²')
# plt.grid(True)
#
# # 绘制第二个子图
# plt.subplot(2, 2, 2)
# plt.plot(x, y2, 'b-', linewidth=2)
# plt.title('正弦函数: y = sin(x)')
# plt.grid(True)
#
# # 绘制第三个子图
# plt.subplot(2, 2, 3)
# plt.plot(x, y3, 'g-', linewidth=2)
# plt.title('指数函数: y = exp(x/3)')
# plt.grid(True)
#
# # 绘制第四个子图
# plt.subplot(2, 2, 4)
# plt.plot(x, y4, 'm-', linewidth=2)
# plt.title('Sigmoid函数: y = 1/(1+exp(-x))')
# plt.grid(True)
#
# plt.tight_layout()
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 创建数据
# x = np.linspace(0, 4*np.pi, 200)
# y = np.sin(x) * np.exp(-x/5)  # 衰减的正弦波
#
# # 绘制曲线
# plt.figure(figsize=(10, 6))
# plt.plot(x, y,
#          color='darkblue',
#          linewidth=2.5,
#          linestyle='-',
#          marker='',
#          markersize=0,
#          label='y = sin(x) * exp(-x/5)')
#
# # 美化图形
# plt.title('衰减正弦波', fontsize=14, fontweight='bold')
# plt.xlabel('x', fontsize=12)
# plt.ylabel('y', fontsize=12)
# plt.grid(True, linestyle='--', alpha=0.7)
# plt.legend(fontsize=10)
#
# # 设置坐标轴范围
# plt.xlim(0, 4*np.pi)
# plt.ylim(-0.5, 1)
#
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 创建数据
# x = np.linspace(-5, 5, 300)
#
# # 不同阶数的多项式
# y1 = x
# y2 = x**2
# y3 = x**3
# y4 = x**4
#
# # 绘制多条曲线
# plt.figure(figsize=(10, 6))
#
# plt.plot(x, y1, label='y = x', linewidth=2)
# plt.plot(x, y2, label='y = x²', linewidth=2)
# plt.plot(x, y3, label='y = x³', linewidth=2)
# plt.plot(x, y4, label='y = x⁴', linewidth=2)
#
# # 图形美化
# plt.title('不同阶数的多项式函数', fontsize=14)
# plt.xlabel('x', fontsize=12)
# plt.ylabel('y', fontsize=12)
# plt.grid(True, alpha=0.3)
# plt.legend(fontsize=10)
# plt.axhline(y=0, color='k', linestyle='-', alpha=0.3)
# plt.axvline(x=0, color='k', linestyle='-', alpha=0.3)
#
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
# from mpl_toolkits.mplot3d import Axes3D
#
# # 创建3D螺旋线数据
# t = np.linspace(0, 4*np.pi, 200)
# x = np.sin(t)
# y = np.cos(t)
# z = t/4
#
# # 绘制3D曲线
# fig = plt.figure(figsize=(10, 8))
# ax = fig.add_subplot(111, projection='3d')
#
# ax.plot(x, y, z, 'b-', linewidth=2)
# ax.set_title('3D螺旋线', fontsize=14)
# ax.set_xlabel('X')
# ax.set_ylabel('Y')
# ax.set_zlabel('Z')
#
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 极坐标数据
# theta = np.linspace(0, 4*np.pi, 300)
# r = np.sin(3*theta)  # 三叶玫瑰线
#
# # 极坐标绘图
# plt.figure(figsize=(8, 8))
# ax = plt.subplot(111, projection='polar')
# ax.plot(theta, r, 'r-', linewidth=2)
# ax.set_title('极坐标曲线: 三叶玫瑰线', va='bottom', fontsize=14)
# ax.grid(True)
#
# plt.show()
# import numpy as np
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
#
# # 创建图形和3D坐标轴
# fig = plt.figure(figsize=(10, 8))
# ax = fig.add_subplot(111, projection='3d')
#
# # 生成参数
# t = np.linspace(0, 2*np.pi, 100)
# s = np.linspace(0, 2*np.pi, 100)
# t, s = np.meshgrid(t, s)
#
# # 爱心参数方程
# x = 16 * np.sin(t) ** 3
# y = 13 * np.cos(t) - 5 * np.cos(2*t) - 2 * np.cos(3*t) - np.cos(4*t)
# z = s * 0  # 创建2D爱心
#
# # 绘制2D爱心
# ax.plot_surface(x, y, z, color='red', alpha=0.9)
# ax.set_title('2D爱心', fontsize=14)
# ax.set_xlabel('X')
# ax.set_ylabel('Y')
# ax.set_zlabel('Z')
#
# plt.show()
# import numpy as np
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
#
# # 创建图形和3D坐标轴
# fig = plt.figure(figsize=(12, 10))
# ax = fig.add_subplot(111, projection='3d')
#
# # 生成网格
# u = np.linspace(0, 2*np.pi, 60)
# v = np.linspace(0, np.pi, 60)
# u, v = np.meshgrid(u, v)
#
# # 3D爱心参数方程
# x = 16 * np.sin(u) ** 3 * np.sin(v)
# y = (13 * np.cos(u) - 5 * np.cos(2*u) - 2 * np.cos(3*u) - np.cos(4*u)) * np.sin(v)
# z = (13 * np.cos(u) - 5 * np.cos(2*u) - 2 * np.cos(3*u) - np.cos(4*u)) * np.cos(v)
#
# # 绘制3D爱心
# ax.plot_surface(x, y, z, color='red', alpha=0.9, rstride=1, cstride=1)
#
# # 设置坐标轴
# ax.set_xlabel('X')
# ax.set_ylabel('Y')
# ax.set_zlabel('Z')
# ax.set_title('3D立体爱心', fontsize=16)
#
# # 设置相等的坐标轴比例
# max_range = np.array([x.max()-x.min(), y.max()-y.min(), z.max()-z.min()]).max() / 2.0
# mid_x = (x.max()+x.min()) * 0.5
# mid_y = (y.max()+y.min()) * 0.5
# mid_z = (z.max()+z.min()) * 0.5
# ax.set_xlim(mid_x - max_range, mid_x + max_range)
# ax.set_ylim(mid_y - max_range, mid_y + max_range)
# ax.set_zlim(mid_z - max_range, mid_z + max_range)
#
# plt.show()
# import numpy as np
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
#
# # 创建图形和3D坐标轴
# fig = plt.figure(figsize=(10, 8))
# ax = fig.add_subplot(111, projection='3d')
#
# # 生成参数
# theta = np.linspace(0, 2*np.pi, 100)
# phi = np.linspace(0, np.pi, 50)
# theta, phi = np.meshgrid(theta, phi)
#
# # 爱心参数方程
# r = 1 - np.sin(phi)
# x = r * np.sin(phi) * np.cos(theta)
# y = r * np.sin(phi) * np.sin(theta)
# z = r * np.cos(phi)
#
# # 绘制3D爱心
# ax.plot_surface(x, y, z, color='red', alpha=0.9, rstride=1, cstride=1)
#
# # 设置坐标轴
# ax.set_xlabel('X')
# ax.set_ylabel('Y')
# ax.set_zlabel('Z')
# ax.set_title('球形爱心', fontsize=16)
#
# # 隐藏坐标轴
# ax.set_xticks([])
# ax.set_yticks([])
# ax.set_zticks([])
#
# plt.show()
# import numpy as np
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
# from skimage import measure
#
# # 创建图形和3D坐标轴
# fig = plt.figure(figsize=(12, 10))
# ax = fig.add_subplot(111, projection='3d')
#
# # 生成网格点
# x = np.linspace(-2, 2, 50)
# y = np.linspace(-2, 2, 50)
# z = np.linspace(-2, 2, 50)
# x, y, z = np.meshgrid(x, y, z)
#
# # 爱心隐函数方程
# # (x^2 + 9/4*y^2 + z^2 - 1)^3 - x^2*z^3 - 9/80*y^2*z^3 = 0
# F = (x**2 + 9/4*y**2 + z**2 - 1)**3 - x**2*z**3 - 9/80*y**2*z**3
#
# # 提取等值面
# verts, faces, _, _ = measure.marching_cubes(F, 0)
#
# # 绘制3D爱心
# ax.plot_trisurf(verts[:, 0], verts[:, 1], faces, verts[:, 2],
#                 color='crimson', alpha=0.9, lw=0)
#
# # 美化图形
# ax.set_xlabel('X')
# ax.set_ylabel('Y')
# ax.set_zlabel('Z')
# ax.set_title('立体爱心 (使用隐函数)', fontsize=16)
#
# # 设置视角
# ax.view_init(elev=20, azim=45)
#
# plt.tight_layout()
# plt.show()
# import numpy as np
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
# from skimage import measure
# # 创建图形和3D坐标轴
# fig = plt.figure(figsize=(12, 10))
# ax = fig.add_subplot(111, projection='3d')
#
# # 生成网格点
# x = np.linspace(-2, 2, 80)
# y = np.linspace(-2, 2, 80)
# z = np.linspace(-2, 2, 80)
# x, y, z = np.meshgrid(x, y, z)
#
# # 爱心隐函数方程
# # (x^2 + 9/4*y^2 + z^2 - 1)^3 - x^2*z^3 - 9/80*y^2*z^3 = 0
# heart = (x**2 + 9/4*y**2 + z**2 - 1)**3 - x**2*z**3 - 9/80*y**2*z**3
#
# # 提取等值面
# verts, faces, _, _ = measure.marching_cubes(heart, 0, spacing=(0.1, 0.1, 0.1))
#
# # 绘制3D爱心
# ax.plot_trisurf(verts[:, 0], verts[:, 1], faces, verts[:, 2],
#                 color='red', alpha=0.9)
#
# ax.set_xlabel('X')
# ax.set_ylabel('Y')
# ax.set_zlabel('Z')
# ax.set_title('隐函数3D爱心', fontsize=16)
#
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 设置中文字体和负号显示
# plt.rcParams['font.sans-serif'].insert(0, 'SimHei')
# plt.rcParams['axes.unicode_minus'] = False
#
# # 创建数据
# x = np.linspace(0, 4*np.pi, 200)
#
# # 创建1x3的子图布局
# fig, axs = plt.subplots(1, 3, figsize=(15, 5))
#
# # 第一个子图：原始正弦波
# axs[0].plot(x, np.sin(x), 'b-', linewidth=2, label='sin(x)')
# axs[0].set_title('原始正弦波')
# axs[0].set_xlabel('x')
# axs[0].set_ylabel('y')
# axs[0].grid(True, alpha=0.3)
# axs[0].legend()
#
# # 第二个子图：带噪声的正弦波（模拟数据点）
# noise = np.random.normal(0, 0.1, len(x))
# y_noisy = np.sin(x) + noise
# axs[1].plot(x, y_noisy, 'ro', markersize=2, alpha=0.5, label='带噪声的数据点')
# axs[1].plot(x, np.sin(x), 'b-', linewidth=2, label='真实曲线')
# axs[1].set_title('带噪声的数据点与真实曲线')
# axs[1].set_xlabel('x')
# axs[1].set_ylabel('y')
# axs[1].grid(True, alpha=0.3)
# axs[1].legend()
#
# # 第三个子图：不同频率的正弦波对比
# axs[2].plot(x, np.sin(x), 'b-', linewidth=2, label='sin(x)')
# axs[2].plot(x, np.sin(2*x), 'r-', linewidth=2, label='sin(2x)')
# axs[2].plot(x, np.sin(0.5*x), 'g-', linewidth=2, label='sin(0.5x)')
# axs[2].set_title('不同频率的正弦波')
# axs[2].set_xlabel('x')
# axs[2].set_ylabel('y')
# axs[2].grid(True, alpha=0.3)
# axs[2].legend()
#
# # 调整子图之间的间距
# plt.tight_layout()
#
# # 显示图形
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 设置中文字体和负号显示
# plt.rcParams['font.sans-serif'].insert(0, 'SimHei')
# plt.rcParams['axes.unicode_minus'] = False
#
# # 创建数据
# x = np.linspace(0, 10, 20)  # 较少的点用于散点图
# y1 = x**2
# y2 = np.sin(x)
#
# # 创建1x2的子图布局
# fig, axs = plt.subplots(1, 2, figsize=(12, 5))
#
# # 第一个子图：折线图
# axs[0].plot(x, y1, 'bo-', linewidth=2, markersize=6, label='y = x²')
# axs[0].set_title('折线图 (带标记点)')
# axs[0].set_xlabel('x')
# axs[0].set_ylabel('y')
# axs[0].grid(True, alpha=0.3)
# axs[0].legend()
#
# # 第二个子图：散点图
# axs[1].scatter(x, y2, c='red', s=50, alpha=0.7, label='y = sin(x)')
# axs[1].plot(x, y2, 'r--', alpha=0.5)  # 添加虚线连接点
# axs[1].set_title('散点图')
# axs[1].set_xlabel('x')
# axs[1].set_ylabel('y')
# axs[1].grid(True, alpha=0.3)
# axs[1].legend()
#
# # 调整子图之间的间距
# plt.tight_layout()
#
# # 显示图形
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
# from scipy.optimize import curve_fit
#
# # 设置中文字体和负号显示
# plt.rcParams['font.sans-serif'].insert(0, 'SimHei')
# plt.rcParams['axes.unicode_minus'] = False
#
# # 生成模拟实验数据
# np.random.seed(42)  # 保证每次运行结果一致
# x_data = np.linspace(0, 10, 20)
# y_data = 2.5 * x_data + 1.2 + np.random.normal(0, 1, len(x_data))
#
# # 定义线性函数用于拟合
# def linear_func(x, a, b):
#     return a * x + b
#
# # 进行曲线拟合
# params, covariance = curve_fit(linear_func, x_data, y_data)
# a, b = params
#
# # 生成拟合曲线
# x_fit = np.linspace(0, 10, 100)
# y_fit = linear_func(x_fit, a, b)
#
# # 创建图形
# plt.figure(figsize=(10, 6))
#
# # 绘制原始数据点
# plt.scatter(x_data, y_data, color='blue', s=50, alpha=0.7, label='实验数据')
#
# # 绘制拟合曲线
# plt.plot(x_fit, y_fit, 'r-', linewidth=2, label=f'拟合曲线: y = {a:.2f}x + {b:.2f}')
#
# # 添加图表元素
# plt.title('实验数据与拟合曲线对比')
# plt.xlabel('x')
# plt.ylabel('y')
# plt.grid(True, alpha=0.3)
# plt.legend()
#
# # 显示图形
# plt.show()
# import matplotlib.pyplot as plt
# import numpy as np
#
# # 设置中文字体和负号显示
# plt.rcParams['font.sans-serif'].insert(0, 'SimHei')
# plt.rcParams['axes.unicode_minus'] = False
#
# # 创建数据点 - 使用较少的数据点确保是直线
# x = np.array([0, 1, 2, 3, 4, 5])
# y = np.array([10, 20, 25, 30, 35, 40])
#
# # 绘制直线折线图
# plt.figure(figsize=(10, 6))
# plt.plot(x, y, 'b-o', linewidth=2, markersize=8)  # 'o'添加标记点，确保看到是直线连接
#
# plt.title('直线折线图示例')
# plt.xlabel('X轴')
# plt.ylabel('Y轴')
# plt.grid(True, alpha=0.3)
#
# # 显示图形
# plt.show()





























